<template>
  <div>
    <div>
      <table>
        <tr>
          <td>
            <button @click="jump">管理</button>
          </td>
          <td>商品名称</td>
          <td>商品价格</td>
          <td>商品图片</td>
        </tr>
        <tr v-for="i in shop">
          <td>
          <td>{{ i.name }}</td>
          <td>{{ i.price }}</td>
          <td><img :src="'http://127.0.0.1:8000'+i.pic" alt="" width="100px"></td>
        </tr>

      </table>
    </div>
  </div>
</template>

<script>
export default {
  name: "show_us",
  data() {
    return {
      user: [],
      shop: [],
      userid: localStorage.getItem('userid')
    }
  },
  methods: {
    get_user() {
      this.$axios.get('user/')
        .then(res => {
          this.user = res.data.list
        })
    },
    get_shop() {
      this.$axios.get('shop/')
        .then(res => {
          this.shop = res.data.list
        })
    },
    jump() {
      if (this.userid) {
        this.$router.push('manage')
      } else {
        alert('未登录')
        this.$router.push('login_us')
      }
    }
  },
  mounted() {
    this.get_user()
    this.get_shop()
  }
}
</script>

<style scoped>

</style>
